import ChartWithAxis from './chartWithAxis';
// import ChartModelUtil from '../chartUtil/ChartModelUtil.js';

class LineChart extends ChartWithAxis {
    getOption(params) {
        super.getOption(params);
        this.addAxises(params);
        this.addSeries(params);
        // console.log('lineChartOption:',params.title,this.option);
        // console.log(JSON.stringify(this.option))
        return this.option;
    }
    addSeries(params){
        let series = [
            {
                name: '',
                type: 'line',
                data: this.processSerieData(params),
                symbolSize:8,
                symbol:'circle',
                smooth:0.5,
                showAllSymbol:true
            }
        ];
        this.option.series=series;
    }
    processSerieData(params){
        let res = [];
        let measure = params.data.measure;
        let dimension = params.data.dimension;
        let searchDate = params.searchDate;
        for(let i = 0; i < measure.length; i++){
            if(dimension[i]==searchDate){
                res.push({
                    value:measure[i],
                    symbol:'',
                    label:{
                        normal:{
                            show:true,
                            formatter:function(value){
                                // console.log(value)
                                return value.value*100 + params.yAxisLabelFormatter||''
                            }
                        }
                    }
                })
            }else{
                res.push(measure[i]);
            }
        }
        return res;
    }
}
export default LineChart;